<?php

class Gmapsprofile_Form_Admin_Geocode extends Engine_Form
{
  public function init()
  {

    $this->setMethod('post');
    $this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array()));
	$this->setDescription('DESCRIPTION UPDATE');

    $this->addElement('Checkbox', 'geocode', array(
      'label' => '',
      'description' => 'Geocode Update Enabled',
    ));

    $this->addElement('Text', 'queries', array(
      'label' => 'Queries',
      'description' => 'geocode requests',
      'required' => true,
      'allowEmpty' => false,
      'validators' => array(
        array('Int', true),
      ),
    ));
	$this->queries->getDecorator( 'Description' )->setOptions( array( 'placement' => 'append' ) );		

    $this->addElement('Text', 'timeout', array(
      'label' => 'Timeout',
      'description' => 'delay between bulk of queries in seconds',
      'required' => true,
      'allowEmpty' => false,
      'validators' => array(
        array('Int', true),
      ),
    ));
	$this->timeout->getDecorator( 'Description' )->setOptions( array( 'placement' => 'append' ) );		

    $this->addElement('Button', 'submit', array(
      'label' => 'Save Settings',
      'type' => 'submit',
	  'decorators' => array('ViewHelper')
    ));
	
	if (Engine_Api::_()->gmapsprofile()->isAddress()) {
	    $this->addElement('Button', 'clear_address', array(
	      'label' => 'Reset previous address coordinates for all members',
	      'type' => 'submit',
		  'decorators' => array('ViewHelper')
	    ));
	
	    $this->addDisplayGroup(array('submit', 'clear_address'), 'buttons');
	    $button_group = $this->getDisplayGroup('buttons');	
	}	
  }  
}